<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>详情页</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/renting/css/public.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/renting/css/header.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/renting/css/bottom.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/renting/css/details.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/renting/css/share.css" type="text/css" />
    <script src="${pageContext.request.contextPath}/renting/js/jQuery-3.4.1.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=3.0&ak=alvW4l5xubkwlk871fGbcGwUlkwdolAa"></script>
</head>

<body>
<div class="main">
    <div class="header">
        <div class="nav">
            <a href="${pageContext.request.contextPath}/renting/index.jsp" class="nav_title">好客租房</a>
            <select class="select">
                <option value="重庆">重庆</option>
                <option value="贵阳">贵阳</option>
                <option value="重庆">重庆</option>
                <option value="贵阳">贵阳</option>
            </select>
            <ul class="nav_ul">
                <li><a href="${pageContext.request.contextPath}/renting/index.jsp">首页</a></li>
                <li><a href="${pageContext.request.contextPath}/renting/pages/onther/Findroom.jsp" style="color: #2981c8;">轻松找房</a></li>
                <li><a href="${pageContext.request.contextPath}/renting/pages/onther/entry.jsp">房东入驻</a></li>
                <li><a href="${pageContext.request.contextPath}/renting/pages/onther/chat_news.jsp">消息</a></li>
                <c:if test="${sessionScope.drom.isHouse==0}">
                    <li><a href="${pageContext.request.contextPath}/userInfo/">房东</a></li>
                </c:if>
                <c:if test="${sessionScope.drom.isHouse==1}">
                    <li><a href="${pageContext.request.contextPath}/userInfo/">主页</a></li>
                </c:if>
                <li><a href="${pageContext.request.contextPath}/renting/pages/onther/login.jsp">登录</a></li>
            </ul>
            <img src="${pageContext.request.contextPath}/renting/img/icon/lianxi-1.png" class="nav_img">
            <p class="nav_phone">
                <span>13301131116</span>
                <span>13301131116</span>
            </p>
        </div>
    </div>
    <div class="content">
        <div class="content_top">
            <div class="top_left">
                <h2>${houseShow.cityName}</h2>
                <p><span>${houseShow.price}<i>元/月</i></span><i>|</i>${houseShow.houseType}<a>|</a>${houseShow.constructionArea}m²</p>
            </div>
            <div style="clear: both;"></div>
        </div>
        <div class="roomInfo">
            <div class="Info_left">
                <div class="slider">
                    <div class="tab">
                        <ul>
                            <li>
                                <img src="${pageContext.request.contextPath}/renting/img/icon/tupian-1.png">
                                <p>室内图(4)</p>
                            </li>
                            <li>
                                <img src="${pageContext.request.contextPath}/renting/img/icon/huxing-5.png">
                                <p>户型图</p>
                            </li>
                            <li>
                                <img src="${pageContext.request.contextPath}/renting/img/icon/ditu-2-copy.png">
                                <p>周边地图</p>
                            </li>
                        </ul>
                    </div>
                    <div class="slider_list show">
                        <div class="prev">
                            <img src="${pageContext.request.contextPath}/renting/img/icon/xingzhuang2copy.png">
                        </div>
                        <div class="ul_list">
                            <ul>
                                <c:forEach items="${imgsShow}" var="u">
                                <li><img src="${pageContext.request.contextPath}/renting/img/${u.housePicture}"></li>
                               </c:forEach></ul>
                        </div>
                        <div class="next">
                            <img src="${pageContext.request.contextPath}/renting/img/icon/xingzhuang2.png">
                        </div>
                    </div>
                    <div class="slider_list">
                        <div class="prev">
                            <img src="${pageContext.request.contextPath}/renting/img/icon/xingzhuang2copy.png">
                        </div>
                        <div class="ul_list">

                        </div>
                        <div class="next">
                            <img src="${pageContext.request.contextPath}/renting/img/icon/xingzhuang2.png">
                        </div>
                    </div>
                </div>
                <div class="Details">
                    <div class="Details_box1">
                        <p>详情介绍</p>
                        <c:if test="${sessionScope.drom!=null}">
                            <p>
									<span id="sc" onclick="shouclik()">
                                            <img id="shou" src="${pageContext.request.contextPath}/renting/img/icon/${boo?"aixin.png":"shoucang-1.png"}">
                                            <span id="shoutu">${boo ? "已收藏":"收藏"}</span>
                                            <input id="texthtml" type="hidden" value="${boo?"0":"1"}">
									</span>
                                <i></i>
                                <span id="qZone">
										<img src="${pageContext.request.contextPath}/renting/img/icon/fenxiang.png">
										分享
									</span>
                                <i></i>
                                <span>
										<img src="${pageContext.request.contextPath}/renting/img/icon/jubao.png">
										举报
									</span>
                            </p>
                            <script>
                                function shouclik(){
                                var text = {"userid":${sessionScope.drom.rid},"houseId":${houseShow.rid}};
                                $.ajax({
                                        url:"${pageContext.request.contextPath}/userInfo/addCollection",// 请求路劲
                                        type:"post",//提交方式
                                        data:{"data":JSON.stringify(text)},
                                        success:function (data){
                                            if(data==1){
                                                $("#shou").attr("src","${pageContext.request.contextPath}/renting/img/icon/aixin.png");
                                                $("#shoutu").text("已收藏");
                                            }else {
                                                $("#shou").attr("src","${pageContext.request.contextPath}/renting/img/icon/shoucang-1.png");
                                                $("#shoutu").text("收藏");
                                            }
                                        }
                                    })
                                }
                            </script>
                        </c:if>
                        <div style="clear: both;"></div>
                    </div>
                    <table border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td>租房类型:</td>
                            <td>${houseShow.rentalType}</td>
                            <td>租金:</td>
                            <td style="color: red;">${houseShow.price}元</td>
                        </tr>
                        <tr>
                            <td>付款方式:</td>
                            <td>${houseShow.paymentMethod}</td>
                            <td>装修情况:</td>
                            <td>${houseShow.renovationCondition}</td>
                        </tr>
                        <tr>
                            <td>房型:</td>
                            <td>${houseShow.houseType}</td>
                            <td>面积:</td>
                            <td>${houseShow.constructionArea}m²</td>
                        </tr>
                        <tr>
                            <td>楼层情况:</td>
                            <td>${houseShow.floorSituation}</td>
                            <td>房间朝向:</td>
                            <td>${houseShow.towards}</td>
                        </tr>
                        <tr>
                            <td>房屋类型:</td>
                            <td>${houseShow.buildingType}</td>
                            <td>小区名:</td>
                            <td>${houseShow.communityName}</td>
                        </tr>
                        <tr>
                            <td>具体地点:</td>
                            <td>${houseShow.communityAddress}</td>
                            <td>房屋配置:</td>
                            <td>${houseShow.housingConfiguration}</td>
                        </tr>
                    </table>
                    <div class="Details_box2">
                        <p>房屋描述</p>
                        <p>
                            ${houseShow.houseDescribe}
                        </p>
                    </div>
                </div>
            </div>
            <div class="Info_right">
                <div class="headImg">
                    <img src="${pageContext.request.contextPath}/renting/img/icon/lianxi-1.png">
                    <p>房东：${userShow.name}</p>
                </div>
                <ul>
                    <li><a href="${pageContext.request.contextPath}/renting/pages/onther/IDcard.jsp">
                        <img src="${pageContext.request.contextPath}/renting/img/icon/shenfenzheng.png">
                        <p>身份证</p></a>
                    </li>
                    <li><a href="">
                        <img src="${pageContext.request.contextPath}/renting/img/icon/yingyezhizhao-1.png">
                        <p>营业执照</p></a>
                    </li>
                    <li><a href="chat_news.jsp">
                        <img src="${pageContext.request.contextPath}/renting/img/icon/xiaoxi.png">
                        <p>私信房东</p></a>
                    </li>
                </ul>
                <p class="tel">联系电话：</p>
                <p class="num"><span>${userShow.phone}</span><span>15585443515</span></p>
                <c:if test="${sessionScope.drom!=null}">
                    <form action="${pageContext.request.contextPath}/userInfo/preset" method="post">
                        <input type="hidden" name="districtName" value="${houseShow.cityName}"> <input type="hidden" name="price" value="${houseShow.price}"><input type="hidden" name="houseType" value="${houseShow.houseType}"><input type="hidden" name="constructionArea" value="${houseShow.constructionArea}">
                        <input type="hidden" name="paymentMethod" value="${houseShow.paymentMethod}"> <input type="hidden" name="towards" value="${houseShow.towards}"><input type="hidden" name="ing" value="${houseShow.houseType}"><input type="hidden" name="housePicture" value="${houseShow.housePicture}">
                        <input type="hidden" name="renovationCondition" value="${houseShow.renovationCondition}"> <input type="hidden" name="phone" value="${userShow.phone}"><input type="hidden" name="communityName" value="${houseShow.communityName}">
                        <input type="hidden" name="userId" value="${houseShow.userId}"><input type="hidden" name="rid" value="${houseShow.rid}">
                        <input type="submit" class="seeroom" value="预约看房"/>
                    </form>
                    <p class="seeinfo"><a href="${pageContext.request.contextPath}/userInfo/preset">查看TA发布的消息</a></p>
                </c:if>
            </div>
            <div style="clear: both;"></div>
        </div>
        <div class="map">
            <p>
                <img src="${pageContext.request.contextPath}/renting/img/icon/ditu-2.png">
                <span>花果园大街一号花果园M区</span>
                <a href="javascript:(0)">地图及交通</a>
            </p>
            <div class="mymap">
                <div id="l-map"></div>
            </div>
            <div class="chat_list" >
                <p>小区问答</p>
                <div id="Ting">
                </div>
                <c:if test="${sessionScope.drom!=null}">
                    <button type="button" class="for_questions">我要提问</button>
                </c:if>
                <span style="margin-top:20px;color: #0b76ac" onclick="wenClick()">显示所有问题</span>
                <!--提问框-->
                <div class="questions_box">
                    <div class="questions_box_title">
                        <span>提问</span>
                        <img src="${pageContext.request.contextPath}/renting/img/icon/cloese.png" >
                    </div>
                    <p style="padding: 10px 15px 0;">你的问题会推送给已租的客户帮你解答</p>
                    <textarea rows="8" cols="55" id="text" placeholder="请提出你的问题哟~~~~"></textarea>
                    <div style="width: 50%;float: right;" class="btn_box">
                        <button type="button">取消</button>
                        <button type="button" onclick="add()">发布</button>
                    </div>
                    <script>
                        function add(){
                            var txt = {"communityId":${houseShow.communityId},"userId":${sessionScope.drom1},"content":$("#text").val(),"replyNumber":0};
                            console.log(txt);
                            $.ajax({
                                url:"${pageContext.request.contextPath}/question/addQuestion",// 请求路劲
                                type:"post",//提交方式
                                data:"data="+JSON.stringify(txt),
                                success:function (data){
                                    console.log(data);
                                }
                            })
                        }
                    </script>
                </div>
            </div>
        </div>
        <div class="interested">
            <p>你可能感兴趣<a href="javascript:(0)"></a></p>
            <ul>
                <a href="${pageContext.request.contextPath}/renting/pages/onther/details.jsp">
                    <li>
                        <img src="${pageContext.request.contextPath}/renting/img/roomshow.png">
                        <p>房东直租，拎包入住</p>
                        <p><span>1500元</span>/整套出租/一室一厅/洗衣机等等</p>
                    </li>
                </a>
                <a href="${pageContext.request.contextPath}/renting/pages/onther/details.jsp">
                    <li>
                        <img src="${pageContext.request.contextPath}/renting/img/roomshow.png">
                        <p>房东直租，拎包入住</p>
                        <p><span>1500元</span>/整套出租/一室一厅/洗衣机等等</p>
                    </li>
                </a>
                <a href="${pageContext.request.contextPath}/renting/pages/onther/details.jsp">
                    <li>
                        <img src="${pageContext.request.contextPath}/renting/img/roomshow.png">
                        <p>房东直租，拎包入住</p>
                        <p><span>1500元</span>/整套出租/一室一厅/洗衣机等等</p>
                    </li>
                </a>
                <a href="${pageContext.request.contextPath}/renting/pages/onther/details.jsp">
                    <li>
                        <img src="${pageContext.request.contextPath}/renting/img/roomshow.png">
                        <p>房东直租，拎包入住</p>
                        <p><span>1500元</span>/整套出租/一室一厅/洗衣机等等</p>
                    </li>
                </a>
            </ul>
        </div>
    </div>
    <div class="bottom">
        <p>沪公网安备 31011402005354号</p>
    </div>
</div>
</body>
</html>
<script src="${pageContext.request.contextPath}/renting/js/share.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/renting/js/details.js"></script>
<script src="${pageContext.request.contextPath}/renting/js/header.js"></script>
<script type="text/javascript">
    var login=sessionStorage.getItem("login");
    var url="";
    if(login==1){
        url="${pageContext.request.contextPath}/renting/pages/tenant/inspection.jsp";
    }
    if(login==2){
        url="${pageContext.request.contextPath}/renting/pages/landlord/release.jsp";
    }
    judge_login(url,"${pageContext.request.contextPath}/renting/pages/onther/login.jsp");
</script>

<script>
    function dateToStr(timestamp) {
        if(timestamp!=null){
            var date = new Date(timestamp);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
            Y = date.getFullYear() + '-';
            M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
            D = date.getDate() + ' ';
            return Y+M+D;
        }else{
            return "";
        }
    };
    $(function (){
        $.ajax({
            url:"${pageContext.request.contextPath}/question/queryQuestionLimit?limit=6&page=1&showWi=2",// 请求路劲
            type:"post",//提交方式
            dataType:"JSON",
            success:function (data){
                console.log(data);
                $.each(data,function (i,j){
                    var answer=$("<div class='questions'><p><span>提问</span>["+j.communityName+"]"+j.content+"<i>"+dateToStr(j.createTime)+"</i><a href='${pageContext.request.contextPath}/question/Ask?rid="+j.rid+"&content="+j.content+"&communityName="+j.communityName+"&time="+dateToStr(j.createTime)+"'>去回答></a></p><p>共"+j.replyNumber+"条回答</p></div>")
                    answer.appendTo("#Ting");
                })
            }
        })
    });
    function wenClick(){
        function dateToStr(timestamp) {
            if(timestamp!=null){
                var date = new Date(timestamp);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
                Y = date.getFullYear() + '-';
                M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
                D = date.getDate() + ' ';
                return Y+M+D;
            }else{
                return "";
            }
        };
        $(function (){
            $("#Ting").html("");
            $.ajax({
                url:"${pageContext.request.contextPath}/question/queryQuestionLimit?limit=0&page=1&showWi=2",// 请求路劲
                type:"post",//提交方式
                dataType:"JSON",
                success:function (data){
                    console.log(data);
                    $.each(data,function (i,j){
                        var answer=$("<div class='questions'><p><span>提问</span>["+j.communityName+"]"+j.content+"<i>"+dateToStr(j.createTime)+"</i><a href='${pageContext.request.contextPath}/question/Ask?rid="+j.rid+"&content="+j.content+"&communityName="+j.communityName+"&time="+dateToStr(j.createTime)+"'>去回答></a></p><p>共"+j.replyNumber+"条回答</p></div>")
                        answer.appendTo("#Ting");
                    })
                }
            })
        });
    }
</script>
